<template>
  <div id="params">
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item><a href="/home">首页</a></el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>分类参数</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <!-- 消息提醒 -->
      <el-row>
        <el-alert
          show-icon
          title="注意：只允许为第三级分类设置相关参数！"
          type="warning"
        >
        </el-alert>
      </el-row>
      <!-- 选择商品分类 -->
      <el-row>
        <el-col> 选择商品分类: </el-col>
        <el-col>
          <el-cascader
            v-model="selectedKeys"
            :options="cascaderOptions"
            :props="cascaderProps"
            @change="handleChange"
          >
          </el-cascader>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'params',
  data() {
    return {
      selectedKeys: [],
      cascaderOptions: [],
      cascaderProps: {
        value: 'cat_id',
        checkStrictly: true,
        label: 'cat_name',
        children: 'children',
      },
    }
  },
  created() {
    this.getOptionData()
  },
  methods: {
    async getOptionData() {
      const { data: res } = await this.$http.get('categories')
      if (res.meta.status !== 200) {
        return this.$message.error('初始化商品分类数据失败！')
      }
      // 把数据列表，赋值给 categoryList
      this.cascaderOptions = res.data
      console.log(this.cascaderOptions)
    },
    handleChange(value) {
      console.log(value)
    },
  },
  computed: {},
}
</script>

<style>
</style>
